package com.movie.util;


import java.sql.*;

public class DBCconnection {
    public final static String driver="com.mysql.cj.jdbc.Driver";
    public final static String url="jdbc:mysql://localhost:3306/ks";
    public final static String user="root";
    public final static String password="1234";
    static {
        try{
            Class.forName(driver);
        }catch(ClassNotFoundException e){
            e.printStackTrace();
        }
    }
    public static Connection getConnection(){
        try{
            return DriverManager.getConnection(url,user,password);
        }catch(SQLException e){
            e.printStackTrace();
        }
        return null;
    }
    public static void close(ResultSet rs, PreparedStatement ps, Connection con){
        try{
            if(rs != null){
                rs.close();
            }
            if(ps != null){
                ps.close();
            }
            if(con != null){
                con.close();
            }
        }catch(SQLException e){
            e.printStackTrace();
        }
    }
}